<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/lib/layui/css/layui.css" media="all">
</head>
<body>
<form class="layui-form" action="">
    <input type="hidden" name="id" th:value="${ctrain.id}">
    <label class="layui-form-label">用户id</label>
    <div class="layui-input-block">
        <input type="text" name="email" th:value="${ctrain.uid}" required lay-verify="required" placeholder="请输入用户id"
               autocomplete="off"
               class="layui-input">
    </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" th:value="${ctrain.title}" required lay-verify="required" placeholder="标签"
                   autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <input type="text" name="email" th:value="${ctrain.primary}" required lay-verify="required" placeholder="请输入邮箱"
                   autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
            <input type="file" name="phone" th:value="${ctrain.picture}" required lay-verify="required"
                   placeholder="图片" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">副本</label>
        <div class="layui-input-block">
            <input type="text" name="copy" th:value="${ctrain.copy}" required lay-verify="required"
                   placeholder="副本" autocomplete="off"
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <select type="text" class="form-control" name="state"  th:value="${ctrain.state}"
                    required lay-verify="required"
                    placeholder="状态" autocomplete="off">
                <option value="发布">发布</option>
                <option value="未发布">未发布</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="/lib/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form', 'jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;

        //监听提交
        form.on('submit(formDemo)', function (data) {

            $.post('/skill/ctrainUpdate', data.field, function (resp) {
                if (resp.code == 0) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                } else {
                    layer.msg(resp.msg);
                }
            })
        });
    });
</script>
</body>
</html>
